<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/12/9
 * Time: 18:51
 */

namespace ztn\iot\sdk;


use ztn\iot\sdk\req\DeviceSettingListReq;
use ztn\iot\sdk\req\DeviceSettingSendReq;
use ztn\iot\sdk\util\HttpTool;

class IotDeviceSettingTool
{
    public static $BASE_PATH = "iot/api/v1/v1/device/setting/";

    public static function list(DeviceSettingListReq $req)
    {
        $path = IotDeviceSettingTool::$BASE_PATH . "list";
        $resStr = HttpTool::doPost($path, json_encode($req));
        if ($resStr) {
            $res = json_decode($resStr);
            if ($res->data) {
                return $res->data;
            }
        }
        return [];
    }

    public static function send(DeviceSettingSendReq $req)
    {
        $path = IotDeviceSettingTool::$BASE_PATH . "send";
        $resStr = HttpTool::doPost($path, json_encode($req));
        if ($resStr) {
            $res = json_decode($resStr);
            if ($res->data) {
                return $res->data;
            }
        }
        return [];
    }
}